<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    request.setAttribute("basePath",basePath);
%>
<!DOCTYPE>
<html>
<head>
    <title>明细信息</title>
    <%@ include file="/resources/js/easyui/taglibs.jsp"%>
    <%@ include file="/resources/js/easyui/_easyui.jsp"%>
    <%@ include file="/resources/js/easyui/_message.jsp"%>
    <%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body class="easyui-layout">
    <form id="addform">
        <table class="tableForm" style="width: 100%;">
            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>版本名称：</label></th>
                <td><input class="easyui-validatebox easyui-textbox" name="versionname" style="width:200px" data-options="required:true" /></td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>版本号：</label></th>
                <td><input class="easyui-validatebox easyui-textbox" name="versioncode" style="width:200px" data-options="required:true" /></td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>硬件名称：</label></th>
                <td>
                    <select id="queryHardwareid" name="hardwareid" class="easyui-combogrid" style="width: 200px;"
                            data-options="editable:false,
                                    required:true,
                                    url:'${basePath}web/hardwaretype/list.json',
                                    panelWidth:420,pagination:true,method:'post',pageSize:5,pageList:[5],
                                    panelHeight:230,
                                    idField: 'hardwareid',
                                    textField: 'hardwarename',
                                    queryParams : {
                                        hardwarename : function(){return $('#hardwarename').val();}
                                    },
                                    columns: [[
                                        {field:'hardwareid',title:'id',hidden:'true'},
                                        {field:'hardwarename',title:'硬件名称',width:100,align:'center'},
                                        {field:'company',title:'公司',width:100,align:'center'},
                                        {field:'version',title:'版本号',width:100,align:'center'}
                                    ]],
                                    fitColumns: true,
                                    toolbar:'#hardwaretype_search'">
                    </select>
                    <div id="hardwaretype_search" style="height: 40px;padding-top: 5px;">
                        <table>
                            <tr>
                                <td><lable style="margin-left:5px">硬件名称:</lable></td>
                                <td>
                                    <input id="hardwareName" type="text" style="width: 100px;" class="easyui-textbox" />
                                </td>
                                <td><a href="javascript:void(0)" style="margin-left:5px" class="easyui-linkbutton" iconCls="icon-search" id="queryHardwareTypeBtn">查询</a></td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>

        </table>
    </form>

<script type="application/javascript">
    function add(){
        if($("#addform").form('validate')){
            $.ajax({
                url:'${basePath}web/hardwareversion/add',
                type : 'POST',
                data : $("#addform").serialize(),
                async : false,
                traditional:true,
                error: function (response) {
                    ViewHelper.func.ajaxErrorMessage(response);
                },
                success: function (ret) {
                    if(ret.result) {
                        $.messager.alert('提示信息！',ret.info,'info');
                        parent.view.closeAddWin(1);
                        $("#addform").form('clear');
                    }else{
                        $.messager.alert('提示','保存失败!','error');
                    }
                }
            });
        }
    }

    $('#queryHardwareTypeBtn').click(function(){
        $('#queryHardwareid').combogrid('grid').datagrid('load',{
            hardwareName : function(){return $('#hardwareName').val();}
        });
    });

</script>
</body>
</html>
